In [1]:
%%HTML
<style>
.container { width:100% } 
</style>


General Linear Regression

In this case study we investigate how much of the fuel consumption of a car can be explained by the

  • number of cylinders,
  • engine displacement,
  • power,
  • weight,
  • acceleration, and
  • the year the car has been introduced into the market.

This data is given in the CSV file cars.csv. In this file, the engine displacement is given in cubic inches and the weight is given in pounds. The fuel consumption is specified as miles per galon and the acceleration is given as the number of seconds until the car reaches 60 miles per hour.

The module csv offers a number of functions for reading and writing csv files.


In [2]:
import csv

Below we read the file cars.csv and store the fuel consumption in the list mpg, while the number of cylinders, the engine displacement, the power, the weight, the acceleration, and the building year are stored as the list of lists Features. Note also that we have added the constant feature $1$ to every list in Features.


In [3]:
with open('cars.csv') as input_file:
    reader     = csv.reader(input_file, delimiter=',')
    line_count = 0
    mpg        = []
    Features   = []
    for row in reader:
        print(row)
        if line_count != 0:  
            mpg     .append(float(row[0]))  
            Features.append([float(x) for x in row[1:6+1]] + [1.0]) 
        line_count += 1


['mpg', 'cyl', 'displacement', 'hp', 'weight', 'acc', 'year', 'name']
['18.0', '8', '307.0', '130.0', '3504.0', '12.0', '70', 'chevrolet chevelle malibu']
['15.0', '8', '350.0', '165.0', '3693.0', '11.5', '70', 'buick skylark 320']
['18.0', '8', '318.0', '150.0', '3436.0', '11.0', '70', 'plymouth satellite']
['16.0', '8', '304.0', '150.0', '3433.0', '12.0', '70', 'amc rebel sst']
['17.0', '8', '302.0', '140.0', '3449.0', '10.5', '70', 'ford torino']
['15.0', '8', '429.0', '198.0', '4341.0', '10.0', '70', 'ford galaxie 500']
['14.0', '8', '454.0', '220.0', '4354.0', '9.0', '70', 'chevrolet impala']
['14.0', '8', '440.0', '215.0', '4312.0', '8.5', '70', 'plymouth fury iii']
['14.0', '8', '455.0', '225.0', '4425.0', '10.0', '70', 'pontiac catalina']
['15.0', '8', '390.0', '190.0', '3850.0', '8.5', '70', 'amc ambassador dpl']
['15.0', '8', '383.0', '170.0', '3563.0', '10.0', '70', 'dodge challenger se']
['14.0', '8', '340.0', '160.0', '3609.0', '8.0', '70', "plymouth 'cuda 340"]
['15.0', '8', '400.0', '150.0', '3761.0', '9.5', '70', 'chevrolet monte carlo']
['14.0', '8', '455.0', '225.0', '3086.0', '10.0', '70', 'buick estate wagon (sw)']
['24.0', '4', '113.0', '95.00', '2372.0', '15.0', '70', 'toyota corona mark ii']
['22.0', '6', '198.0', '95.00', '2833.0', '15.5', '70', 'plymouth duster']
['18.0', '6', '199.0', '97.00', '2774.0', '15.5', '70', 'amc hornet']
['21.0', '6', '200.0', '85.00', '2587.0', '16.0', '70', 'ford maverick']
['27.0', '4', '97.00', '88.00', '2130.0', '14.5', '70', 'datsun pl510']
['26.0', '4', '97.00', '46.00', '1835.0', '20.5', '70', 'volkswagen 1131 deluxe sedan']
['25.0', '4', '110.0', '87.00', '2672.0', '17.5', '70', 'peugeot 504']
['24.0', '4', '107.0', '90.00', '2430.0', '14.5', '70', 'audi 100 ls']
['25.0', '4', '104.0', '95.00', '2375.0', '17.5', '70', 'saab 99e']
['26.0', '4', '121.0', '113.0', '2234.0', '12.5', '70', 'bmw 2002']
['21.0', '6', '199.0', '90.00', '2648.0', '15.0', '70', 'amc gremlin']
['10.0', '8', '360.0', '215.0', '4615.0', '14.0', '70', 'ford f250']
['10.0', '8', '307.0', '200.0', '4376.0', '15.0', '70', 'chevy c20']
['11.0', '8', '318.0', '210.0', '4382.0', '13.5', '70', 'dodge d200']
['9.0', '8', '304.0', '193.0', '4732.0', '18.5', '70', 'hi 1200d']
['27.0', '4', '97.00', '88.00', '2130.0', '14.5', '71', 'datsun pl510']
['28.0', '4', '140.0', '90.00', '2264.0', '15.5', '71', 'chevrolet vega 2300']
['25.0', '4', '113.0', '95.00', '2228.0', '14.0', '71', 'toyota corona']
['19.0', '6', '232.0', '100.0', '2634.0', '13.0', '71', 'amc gremlin']
['16.0', '6', '225.0', '105.0', '3439.0', '15.5', '71', 'plymouth satellite custom']
['17.0', '6', '250.0', '100.0', '3329.0', '15.5', '71', 'chevrolet chevelle malibu']
['19.0', '6', '250.0', '88.00', '3302.0', '15.5', '71', 'ford torino 500']
['18.0', '6', '232.0', '100.0', '3288.0', '15.5', '71', 'amc matador']
['14.0', '8', '350.0', '165.0', '4209.0', '12.0', '71', 'chevrolet impala']
['14.0', '8', '400.0', '175.0', '4464.0', '11.5', '71', 'pontiac catalina brougham']
['14.0', '8', '351.0', '153.0', '4154.0', '13.5', '71', 'ford galaxie 500']
['14.0', '8', '318.0', '150.0', '4096.0', '13.0', '71', 'plymouth fury iii']
['12.0', '8', '383.0', '180.0', '4955.0', '11.5', '71', 'dodge monaco (sw)']
['13.0', '8', '400.0', '170.0', '4746.0', '12.0', '71', 'ford country squire (sw)']
['13.0', '8', '400.0', '175.0', '5140.0', '12.0', '71', 'pontiac safari (sw)']
['18.0', '6', '258.0', '110.0', '2962.0', '13.5', '71', 'amc hornet sportabout (sw)']
['22.0', '4', '140.0', '72.00', '2408.0', '19.0', '71', 'chevrolet vega (sw)']
['19.0', '6', '250.0', '100.0', '3282.0', '15.0', '71', 'pontiac firebird']
['18.0', '6', '250.0', '88.00', '3139.0', '14.5', '71', 'ford mustang']
['23.0', '4', '122.0', '86.00', '2220.0', '14.0', '71', 'mercury capri 2000']
['28.0', '4', '116.0', '90.00', '2123.0', '14.0', '71', 'opel 1900']
['30.0', '4', '79.00', '70.00', '2074.0', '19.5', '71', 'peugeot 304']
['30.0', '4', '88.00', '76.00', '2065.0', '14.5', '71', 'fiat 124b']
['31.0', '4', '71.00', '65.00', '1773.0', '19.0', '71', 'toyota corolla 1200']
['35.0', '4', '72.00', '69.00', '1613.0', '18.0', '71', 'datsun 1200']
['27.0', '4', '97.00', '60.00', '1834.0', '19.0', '71', 'volkswagen model 111']
['26.0', '4', '91.00', '70.00', '1955.0', '20.5', '71', 'plymouth cricket']
['24.0', '4', '113.0', '95.00', '2278.0', '15.5', '72', 'toyota corona hardtop']
['25.0', '4', '97.50', '80.00', '2126.0', '17.0', '72', 'dodge colt hardtop']
['23.0', '4', '97.00', '54.00', '2254.0', '23.5', '72', 'volkswagen type 3']
['20.0', '4', '140.0', '90.00', '2408.0', '19.5', '72', 'chevrolet vega']
['21.0', '4', '122.0', '86.00', '2226.0', '16.5', '72', 'ford pinto runabout']
['13.0', '8', '350.0', '165.0', '4274.0', '12.0', '72', 'chevrolet impala']
['14.0', '8', '400.0', '175.0', '4385.0', '12.0', '72', 'pontiac catalina']
['15.0', '8', '318.0', '150.0', '4135.0', '13.5', '72', 'plymouth fury iii']
['14.0', '8', '351.0', '153.0', '4129.0', '13.0', '72', 'ford galaxie 500']
['17.0', '8', '304.0', '150.0', '3672.0', '11.5', '72', 'amc ambassador sst']
['11.0', '8', '429.0', '208.0', '4633.0', '11.0', '72', 'mercury marquis']
['13.0', '8', '350.0', '155.0', '4502.0', '13.5', '72', 'buick lesabre custom']
['12.0', '8', '350.0', '160.0', '4456.0', '13.5', '72', 'oldsmobile delta 88 royale']
['13.0', '8', '400.0', '190.0', '4422.0', '12.5', '72', 'chrysler newport royal']
['19.0', '3', '70.00', '97.00', '2330.0', '13.5', '72', 'mazda rx2 coupe']
['15.0', '8', '304.0', '150.0', '3892.0', '12.5', '72', 'amc matador (sw)']
['13.0', '8', '307.0', '130.0', '4098.0', '14.0', '72', 'chevrolet chevelle concours (sw)']
['13.0', '8', '302.0', '140.0', '4294.0', '16.0', '72', 'ford gran torino (sw)']
['14.0', '8', '318.0', '150.0', '4077.0', '14.0', '72', 'plymouth satellite custom (sw)']
['18.0', '4', '121.0', '112.0', '2933.0', '14.5', '72', 'volvo 145e (sw)']
['22.0', '4', '121.0', '76.00', '2511.0', '18.0', '72', 'volkswagen 411 (sw)']
['21.0', '4', '120.0', '87.00', '2979.0', '19.5', '72', 'peugeot 504 (sw)']
['26.0', '4', '96.00', '69.00', '2189.0', '18.0', '72', 'renault 12 (sw)']
['22.0', '4', '122.0', '86.00', '2395.0', '16.0', '72', 'ford pinto (sw)']
['28.0', '4', '97.00', '92.00', '2288.0', '17.0', '72', 'datsun 510 (sw)']
['23.0', '4', '120.0', '97.00', '2506.0', '14.5', '72', 'toyouta corona mark ii (sw)']
['28.0', '4', '98.00', '80.00', '2164.0', '15.0', '72', 'dodge colt (sw)']
['27.0', '4', '97.00', '88.00', '2100.0', '16.5', '72', 'toyota corolla 1600 (sw)']
['13.0', '8', '350.0', '175.0', '4100.0', '13.0', '73', 'buick century 350']
['14.0', '8', '304.0', '150.0', '3672.0', '11.5', '73', 'amc matador']
['13.0', '8', '350.0', '145.0', '3988.0', '13.0', '73', 'chevrolet malibu']
['14.0', '8', '302.0', '137.0', '4042.0', '14.5', '73', 'ford gran torino']
['15.0', '8', '318.0', '150.0', '3777.0', '12.5', '73', 'dodge coronet custom']
['12.0', '8', '429.0', '198.0', '4952.0', '11.5', '73', 'mercury marquis brougham']
['13.0', '8', '400.0', '150.0', '4464.0', '12.0', '73', 'chevrolet caprice classic']
['13.0', '8', '351.0', '158.0', '4363.0', '13.0', '73', 'ford ltd']
['14.0', '8', '318.0', '150.0', '4237.0', '14.5', '73', 'plymouth fury gran sedan']
['13.0', '8', '440.0', '215.0', '4735.0', '11.0', '73', 'chrysler new yorker brougham']
['12.0', '8', '455.0', '225.0', '4951.0', '11.0', '73', 'buick electra 225 custom']
['13.0', '8', '360.0', '175.0', '3821.0', '11.0', '73', 'amc ambassador brougham']
['18.0', '6', '225.0', '105.0', '3121.0', '16.5', '73', 'plymouth valiant']
['16.0', '6', '250.0', '100.0', '3278.0', '18.0', '73', 'chevrolet nova custom']
['18.0', '6', '232.0', '100.0', '2945.0', '16.0', '73', 'amc hornet']
['18.0', '6', '250.0', '88.00', '3021.0', '16.5', '73', 'ford maverick']
['23.0', '6', '198.0', '95.00', '2904.0', '16.0', '73', 'plymouth duster']
['26.0', '4', '97.00', '46.00', '1950.0', '21.0', '73', 'volkswagen super beetle']
['11.0', '8', '400.0', '150.0', '4997.0', '14.0', '73', 'chevrolet impala']
['12.0', '8', '400.0', '167.0', '4906.0', '12.5', '73', 'ford country']
['13.0', '8', '360.0', '170.0', '4654.0', '13.0', '73', 'plymouth custom suburb']
['12.0', '8', '350.0', '180.0', '4499.0', '12.5', '73', 'oldsmobile vista cruiser']
['18.0', '6', '232.0', '100.0', '2789.0', '15.0', '73', 'amc gremlin']
['20.0', '4', '97.00', '88.00', '2279.0', '19.0', '73', 'toyota carina']
['21.0', '4', '140.0', '72.00', '2401.0', '19.5', '73', 'chevrolet vega']
['22.0', '4', '108.0', '94.00', '2379.0', '16.5', '73', 'datsun 610']
['18.0', '3', '70.00', '90.00', '2124.0', '13.5', '73', 'maxda rx3']
['19.0', '4', '122.0', '85.00', '2310.0', '18.5', '73', 'ford pinto']
['21.0', '6', '155.0', '107.0', '2472.0', '14.0', '73', 'mercury capri v6']
['26.0', '4', '98.00', '90.00', '2265.0', '15.5', '73', 'fiat 124 sport coupe']
['15.0', '8', '350.0', '145.0', '4082.0', '13.0', '73', 'chevrolet monte carlo s']
['16.0', '8', '400.0', '230.0', '4278.0', '9.50', '73', 'pontiac grand prix']
['29.0', '4', '68.00', '49.00', '1867.0', '19.5', '73', 'fiat 128']
['24.0', '4', '116.0', '75.00', '2158.0', '15.5', '73', 'opel manta']
['20.0', '4', '114.0', '91.00', '2582.0', '14.0', '73', 'audi 100ls']
['19.0', '4', '121.0', '112.0', '2868.0', '15.5', '73', 'volvo 144ea']
['15.0', '8', '318.0', '150.0', '3399.0', '11.0', '73', 'dodge dart custom']
['24.0', '4', '121.0', '110.0', '2660.0', '14.0', '73', 'saab 99le']
['20.0', '6', '156.0', '122.0', '2807.0', '13.5', '73', 'toyota mark ii']
['11.0', '8', '350.0', '180.0', '3664.0', '11.0', '73', 'oldsmobile omega']
['20.0', '6', '198.0', '95.00', '3102.0', '16.5', '74', 'plymouth duster']
['19.0', '6', '232.0', '100.0', '2901.0', '16.0', '74', 'amc hornet']
['15.0', '6', '250.0', '100.0', '3336.0', '17.0', '74', 'chevrolet nova']
['31.0', '4', '79.00', '67.00', '1950.0', '19.0', '74', 'datsun b210']
['26.0', '4', '122.0', '80.00', '2451.0', '16.5', '74', 'ford pinto']
['32.0', '4', '71.00', '65.00', '1836.0', '21.0', '74', 'toyota corolla 1200']
['25.0', '4', '140.0', '75.00', '2542.0', '17.0', '74', 'chevrolet vega']
['16.0', '6', '250.0', '100.0', '3781.0', '17.0', '74', 'chevrolet chevelle malibu classic']
['16.0', '6', '258.0', '110.0', '3632.0', '18.0', '74', 'amc matador']
['18.0', '6', '225.0', '105.0', '3613.0', '16.5', '74', 'plymouth satellite sebring']
['16.0', '8', '302.0', '140.0', '4141.0', '14.0', '74', 'ford gran torino']
['13.0', '8', '350.0', '150.0', '4699.0', '14.5', '74', 'buick century luxus (sw)']
['14.0', '8', '318.0', '150.0', '4457.0', '13.5', '74', 'dodge coronet custom (sw)']
['14.0', '8', '302.0', '140.0', '4638.0', '16.0', '74', 'ford gran torino (sw)']
['14.0', '8', '304.0', '150.0', '4257.0', '15.5', '74', 'amc matador (sw)']
['29.0', '4', '98.00', '83.00', '2219.0', '16.5', '74', 'audi fox']
['26.0', '4', '79.00', '67.00', '1963.0', '15.5', '74', 'volkswagen dasher']
['26.0', '4', '97.00', '78.00', '2300.0', '14.5', '74', 'opel manta']
['31.0', '4', '76.00', '52.00', '1649.0', '16.5', '74', 'toyota corona']
['32.0', '4', '83.00', '61.00', '2003.0', '19.0', '74', 'datsun 710']
['28.0', '4', '90.00', '75.00', '2125.0', '14.5', '74', 'dodge colt']
['24.0', '4', '90.00', '75.00', '2108.0', '15.5', '74', 'fiat 128']
['26.0', '4', '116.0', '75.00', '2246.0', '14.0', '74', 'fiat 124 tc']
['24.0', '4', '120.0', '97.00', '2489.0', '15.0', '74', 'honda civic']
['26.0', '4', '108.0', '93.00', '2391.0', '15.5', '74', 'subaru']
['31.0', '4', '79.00', '67.00', '2000.0', '16.0', '74', 'fiat x1.9']
['19.0', '6', '225.0', '95.00', '3264.0', '16.0', '75', 'plymouth valiant custom']
['18.0', '6', '250.0', '105.0', '3459.0', '16.0', '75', 'chevrolet nova']
['15.0', '6', '250.0', '72.00', '3432.0', '21.0', '75', 'mercury monarch']
['15.0', '6', '250.0', '72.00', '3158.0', '19.5', '75', 'ford maverick']
['16.0', '8', '400.0', '170.0', '4668.0', '11.5', '75', 'pontiac catalina']
['15.0', '8', '350.0', '145.0', '4440.0', '14.0', '75', 'chevrolet bel air']
['16.0', '8', '318.0', '150.0', '4498.0', '14.5', '75', 'plymouth grand fury']
['14.0', '8', '351.0', '148.0', '4657.0', '13.5', '75', 'ford ltd']
['17.0', '6', '231.0', '110.0', '3907.0', '21.0', '75', 'buick century']
['16.0', '6', '250.0', '105.0', '3897.0', '18.5', '75', 'chevroelt chevelle malibu']
['15.0', '6', '258.0', '110.0', '3730.0', '19.0', '75', 'amc matador']
['18.0', '6', '225.0', '95.00', '3785.0', '19.0', '75', 'plymouth fury']
['21.0', '6', '231.0', '110.0', '3039.0', '15.0', '75', 'buick skyhawk']
['20.0', '8', '262.0', '110.0', '3221.0', '13.5', '75', 'chevrolet monza 2+2']
['13.0', '8', '302.0', '129.0', '3169.0', '12.0', '75', 'ford mustang ii']
['29.0', '4', '97.00', '75.00', '2171.0', '16.0', '75', 'toyota corolla']
['23.0', '4', '140.0', '83.00', '2639.0', '17.0', '75', 'ford pinto']
['20.0', '6', '232.0', '100.0', '2914.0', '16.0', '75', 'amc gremlin']
['23.0', '4', '140.0', '78.00', '2592.0', '18.5', '75', 'pontiac astro']
['24.0', '4', '134.0', '96.00', '2702.0', '13.5', '75', 'toyota corona']
['25.0', '4', '90.00', '71.00', '2223.0', '16.5', '75', 'volkswagen dasher']
['24.0', '4', '119.0', '97.00', '2545.0', '17.0', '75', 'datsun 710']
['18.0', '6', '171.0', '97.00', '2984.0', '14.5', '75', 'ford pinto']
['29.0', '4', '90.00', '70.00', '1937.0', '14.0', '75', 'volkswagen rabbit']
['19.0', '6', '232.0', '90.00', '3211.0', '17.0', '75', 'amc pacer']
['23.0', '4', '115.0', '95.00', '2694.0', '15.0', '75', 'audi 100ls']
['23.0', '4', '120.0', '88.00', '2957.0', '17.0', '75', 'peugeot 504']
['22.0', '4', '121.0', '98.00', '2945.0', '14.5', '75', 'volvo 244dl']
['25.0', '4', '121.0', '115.0', '2671.0', '13.5', '75', 'saab 99le']
['33.0', '4', '91.00', '53.00', '1795.0', '17.5', '75', 'honda civic cvcc']
['28.0', '4', '107.0', '86.00', '2464.0', '15.5', '76', 'fiat 131']
['25.0', '4', '116.0', '81.00', '2220.0', '16.9', '76', 'opel 1900']
['25.0', '4', '140.0', '92.00', '2572.0', '14.9', '76', 'capri ii']
['26.0', '4', '98.00', '79.00', '2255.0', '17.7', '76', 'dodge colt']
['27.0', '4', '101.0', '83.00', '2202.0', '15.3', '76', 'renault 12tl']
['17.5', '8', '305.0', '140.0', '4215.0', '13.0', '76', 'chevrolet chevelle malibu classic']
['16.0', '8', '318.0', '150.0', '4190.0', '13.0', '76', 'dodge coronet brougham']
['15.5', '8', '304.0', '120.0', '3962.0', '13.9', '76', 'amc matador']
['14.5', '8', '351.0', '152.0', '4215.0', '12.8', '76', 'ford gran torino']
['22.0', '6', '225.0', '100.0', '3233.0', '15.4', '76', 'plymouth valiant']
['22.0', '6', '250.0', '105.0', '3353.0', '14.5', '76', 'chevrolet nova']
['24.0', '6', '200.0', '81.00', '3012.0', '17.6', '76', 'ford maverick']
['22.5', '6', '232.0', '90.00', '3085.0', '17.6', '76', 'amc hornet']
['29.0', '4', '85.00', '52.00', '2035.0', '22.2', '76', 'chevrolet chevette']
['24.5', '4', '98.00', '60.00', '2164.0', '22.1', '76', 'chevrolet woody']
['29.0', '4', '90.00', '70.00', '1937.0', '14.2', '76', 'vw rabbit']
['33.0', '4', '91.00', '53.00', '1795.0', '17.4', '76', 'honda civic']
['20.0', '6', '225.0', '100.0', '3651.0', '17.7', '76', 'dodge aspen se']
['18.0', '6', '250.0', '78.00', '3574.0', '21.0', '76', 'ford granada ghia']
['18.5', '6', '250.0', '110.0', '3645.0', '16.2', '76', 'pontiac ventura sj']
['17.5', '6', '258.0', '95.00', '3193.0', '17.8', '76', 'amc pacer d/l']
['29.5', '4', '97.00', '71.00', '1825.0', '12.2', '76', 'volkswagen rabbit']
['32.0', '4', '85.00', '70.00', '1990.0', '17.0', '76', 'datsun b-210']
['28.0', '4', '97.00', '75.00', '2155.0', '16.4', '76', 'toyota corolla']
['26.5', '4', '140.0', '72.00', '2565.0', '13.6', '76', 'ford pinto']
['20.0', '4', '130.0', '102.0', '3150.0', '15.7', '76', 'volvo 245']
['13.0', '8', '318.0', '150.0', '3940.0', '13.2', '76', 'plymouth volare premier v8']
['19.0', '4', '120.0', '88.00', '3270.0', '21.9', '76', 'peugeot 504']
['19.0', '6', '156.0', '108.0', '2930.0', '15.5', '76', 'toyota mark ii']
['16.5', '6', '168.0', '120.0', '3820.0', '16.7', '76', 'mercedes-benz 280s']
['16.5', '8', '350.0', '180.0', '4380.0', '12.1', '76', 'cadillac seville']
['13.0', '8', '350.0', '145.0', '4055.0', '12.0', '76', 'chevy c10']
['13.0', '8', '302.0', '130.0', '3870.0', '15.0', '76', 'ford f108']
['13.0', '8', '318.0', '150.0', '3755.0', '14.0', '76', 'dodge d100']
['31.5', '4', '98.00', '68.00', '2045.0', '18.5', '77', 'honda accord cvcc']
['30.0', '4', '111.0', '80.00', '2155.0', '14.8', '77', 'buick opel isuzu deluxe']
['36.0', '4', '79.00', '58.00', '1825.0', '18.6', '77', 'renault 5 gtl']
['25.5', '4', '122.0', '96.00', '2300.0', '15.5', '77', 'plymouth arrow gs']
['33.5', '4', '85.00', '70.00', '1945.0', '16.8', '77', 'datsun f-10 hatchback']
['17.5', '8', '305.0', '145.0', '3880.0', '12.5', '77', 'chevrolet caprice classic']
['17.0', '8', '260.0', '110.0', '4060.0', '19.0', '77', 'oldsmobile cutlass supreme']
['15.5', '8', '318.0', '145.0', '4140.0', '13.7', '77', 'dodge monaco brougham']
['15.0', '8', '302.0', '130.0', '4295.0', '14.9', '77', 'mercury cougar brougham']
['17.5', '6', '250.0', '110.0', '3520.0', '16.4', '77', 'chevrolet concours']
['20.5', '6', '231.0', '105.0', '3425.0', '16.9', '77', 'buick skylark']
['19.0', '6', '225.0', '100.0', '3630.0', '17.7', '77', 'plymouth volare custom']
['18.5', '6', '250.0', '98.00', '3525.0', '19.0', '77', 'ford granada']
['16.0', '8', '400.0', '180.0', '4220.0', '11.1', '77', 'pontiac grand prix lj']
['15.5', '8', '350.0', '170.0', '4165.0', '11.4', '77', 'chevrolet monte carlo landau']
['15.5', '8', '400.0', '190.0', '4325.0', '12.2', '77', 'chrysler cordoba']
['16.0', '8', '351.0', '149.0', '4335.0', '14.5', '77', 'ford thunderbird']
['29.0', '4', '97.00', '78.00', '1940.0', '14.5', '77', 'volkswagen rabbit custom']
['24.5', '4', '151.0', '88.00', '2740.0', '16.0', '77', 'pontiac sunbird coupe']
['26.0', '4', '97.00', '75.00', '2265.0', '18.2', '77', 'toyota corolla liftback']
['25.5', '4', '140.0', '89.00', '2755.0', '15.8', '77', 'ford mustang ii 2+2']
['30.5', '4', '98.00', '63.00', '2051.0', '17.0', '77', 'chevrolet chevette']
['33.5', '4', '98.00', '83.00', '2075.0', '15.9', '77', 'dodge colt m/m']
['30.0', '4', '97.00', '67.00', '1985.0', '16.4', '77', 'subaru dl']
['30.5', '4', '97.00', '78.00', '2190.0', '14.1', '77', 'volkswagen dasher']
['22.0', '6', '146.0', '97.00', '2815.0', '14.5', '77', 'datsun 810']
['21.5', '4', '121.0', '110.0', '2600.0', '12.8', '77', 'bmw 320i']
['21.5', '3', '80.00', '110.0', '2720.0', '13.5', '77', 'mazda rx-4']
['43.1', '4', '90.00', '48.00', '1985.0', '21.5', '78', 'volkswagen rabbit custom diesel']
['36.1', '4', '98.00', '66.00', '1800.0', '14.4', '78', 'ford fiesta']
['32.8', '4', '78.00', '52.00', '1985.0', '19.4', '78', 'mazda glc deluxe']
['39.4', '4', '85.00', '70.00', '2070.0', '18.6', '78', 'datsun b210 gx']
['36.1', '4', '91.00', '60.00', '1800.0', '16.4', '78', 'honda civic cvcc']
['19.9', '8', '260.0', '110.0', '3365.0', '15.5', '78', 'oldsmobile cutlass salon brougham']
['19.4', '8', '318.0', '140.0', '3735.0', '13.2', '78', 'dodge diplomat']
['20.2', '8', '302.0', '139.0', '3570.0', '12.8', '78', 'mercury monarch ghia']
['19.2', '6', '231.0', '105.0', '3535.0', '19.2', '78', 'pontiac phoenix lj']
['20.5', '6', '200.0', '95.00', '3155.0', '18.2', '78', 'chevrolet malibu']
['20.2', '6', '200.0', '85.00', '2965.0', '15.8', '78', 'ford fairmont (auto)']
['25.1', '4', '140.0', '88.00', '2720.0', '15.4', '78', 'ford fairmont (man)']
['20.5', '6', '225.0', '100.0', '3430.0', '17.2', '78', 'plymouth volare']
['19.4', '6', '232.0', '90.00', '3210.0', '17.2', '78', 'amc concord']
['20.6', '6', '231.0', '105.0', '3380.0', '15.8', '78', 'buick century special']
['20.8', '6', '200.0', '85.00', '3070.0', '16.7', '78', 'mercury zephyr']
['18.6', '6', '225.0', '110.0', '3620.0', '18.7', '78', 'dodge aspen']
['18.1', '6', '258.0', '120.0', '3410.0', '15.1', '78', 'amc concord d/l']
['19.2', '8', '305.0', '145.0', '3425.0', '13.2', '78', 'chevrolet monte carlo landau']
['17.7', '6', '231.0', '165.0', '3445.0', '13.4', '78', 'buick regal sport coupe (turbo)']
['18.1', '8', '302.0', '139.0', '3205.0', '11.2', '78', 'ford futura']
['17.5', '8', '318.0', '140.0', '4080.0', '13.7', '78', 'dodge magnum xe']
['30.0', '4', '98.00', '68.00', '2155.0', '16.5', '78', 'chevrolet chevette']
['27.5', '4', '134.0', '95.00', '2560.0', '14.2', '78', 'toyota corona']
['27.2', '4', '119.0', '97.00', '2300.0', '14.7', '78', 'datsun 510']
['30.9', '4', '105.0', '75.00', '2230.0', '14.5', '78', 'dodge omni']
['21.1', '4', '134.0', '95.00', '2515.0', '14.8', '78', 'toyota celica gt liftback']
['23.2', '4', '156.0', '105.0', '2745.0', '16.7', '78', 'plymouth sapporo']
['23.8', '4', '151.0', '85.00', '2855.0', '17.6', '78', 'oldsmobile starfire sx']
['23.9', '4', '119.0', '97.00', '2405.0', '14.9', '78', 'datsun 200-sx']
['20.3', '5', '131.0', '103.0', '2830.0', '15.9', '78', 'audi 5000']
['17.0', '6', '163.0', '125.0', '3140.0', '13.6', '78', 'volvo 264gl']
['21.6', '4', '121.0', '115.0', '2795.0', '15.7', '78', 'saab 99gle']
['16.2', '6', '163.0', '133.0', '3410.0', '15.8', '78', 'peugeot 604sl']
['31.5', '4', '89.00', '71.00', '1990.0', '14.9', '78', 'volkswagen scirocco']
['29.5', '4', '98.00', '68.00', '2135.0', '16.6', '78', 'honda accord lx']
['21.5', '6', '231.0', '115.0', '3245.0', '15.4', '79', 'pontiac lemans v6']
['19.8', '6', '200.0', '85.00', '2990.0', '18.2', '79', 'mercury zephyr 6']
['22.3', '4', '140.0', '88.00', '2890.0', '17.3', '79', 'ford fairmont 4']
['20.2', '6', '232.0', '90.00', '3265.0', '18.2', '79', 'amc concord dl 6']
['20.6', '6', '225.0', '110.0', '3360.0', '16.6', '79', 'dodge aspen 6']
['17.0', '8', '305.0', '130.0', '3840.0', '15.4', '79', 'chevrolet caprice classic']
['17.6', '8', '302.0', '129.0', '3725.0', '13.4', '79', 'ford ltd landau']
['16.5', '8', '351.0', '138.0', '3955.0', '13.2', '79', 'mercury grand marquis']
['18.2', '8', '318.0', '135.0', '3830.0', '15.2', '79', 'dodge st. regis']
['16.9', '8', '350.0', '155.0', '4360.0', '14.9', '79', 'buick estate wagon (sw)']
['15.5', '8', '351.0', '142.0', '4054.0', '14.3', '79', 'ford country squire (sw)']
['19.2', '8', '267.0', '125.0', '3605.0', '15.0', '79', 'chevrolet malibu classic (sw)']
['18.5', '8', '360.0', '150.0', '3940.0', '13.0', '79', 'chrysler lebaron town @ country (sw)']
['31.9', '4', '89.00', '71.00', '1925.0', '14.0', '79', 'vw rabbit custom']
['34.1', '4', '86.00', '65.00', '1975.0', '15.2', '79', 'maxda glc deluxe']
['35.7', '4', '98.00', '80.00', '1915.0', '14.4', '79', 'dodge colt hatchback custom']
['27.4', '4', '121.0', '80.00', '2670.0', '15.0', '79', 'amc spirit dl']
['25.4', '5', '183.0', '77.00', '3530.0', '20.1', '79', 'mercedes benz 300d']
['23.0', '8', '350.0', '125.0', '3900.0', '17.4', '79', 'cadillac eldorado']
['27.2', '4', '141.0', '71.00', '3190.0', '24.8', '79', 'peugeot 504']
['23.9', '8', '260.0', '90.00', '3420.0', '22.2', '79', 'oldsmobile cutlass salon brougham']
['34.2', '4', '105.0', '70.00', '2200.0', '13.2', '79', 'plymouth horizon']
['34.5', '4', '105.0', '70.00', '2150.0', '14.9', '79', 'plymouth horizon tc3']
['31.8', '4', '85.00', '65.00', '2020.0', '19.2', '79', 'datsun 210']
['37.3', '4', '91.00', '69.00', '2130.0', '14.7', '79', 'fiat strada custom']
['28.4', '4', '151.0', '90.00', '2670.0', '16.0', '79', 'buick skylark limited']
['28.8', '6', '173.0', '115.0', '2595.0', '11.3', '79', 'chevrolet citation']
['26.8', '6', '173.0', '115.0', '2700.0', '12.9', '79', 'oldsmobile omega brougham']
['33.5', '4', '151.0', '90.00', '2556.0', '13.2', '79', 'pontiac phoenix']
['41.5', '4', '98.00', '76.00', '2144.0', '14.7', '80', 'vw rabbit']
['38.1', '4', '89.00', '60.00', '1968.0', '18.8', '80', 'toyota corolla tercel']
['32.1', '4', '98.00', '70.00', '2120.0', '15.5', '80', 'chevrolet chevette']
['37.2', '4', '86.00', '65.00', '2019.0', '16.4', '80', 'datsun 310']
['28.0', '4', '151.0', '90.00', '2678.0', '16.5', '80', 'chevrolet citation']
['26.4', '4', '140.0', '88.00', '2870.0', '18.1', '80', 'ford fairmont']
['24.3', '4', '151.0', '90.00', '3003.0', '20.1', '80', 'amc concord']
['19.1', '6', '225.0', '90.00', '3381.0', '18.7', '80', 'dodge aspen']
['34.3', '4', '97.00', '78.00', '2188.0', '15.8', '80', 'audi 4000']
['29.8', '4', '134.0', '90.00', '2711.0', '15.5', '80', 'toyota corona liftback']
['31.3', '4', '120.0', '75.00', '2542.0', '17.5', '80', 'mazda 626']
['37.0', '4', '119.0', '92.00', '2434.0', '15.0', '80', 'datsun 510 hatchback']
['32.2', '4', '108.0', '75.00', '2265.0', '15.2', '80', 'toyota corolla']
['46.6', '4', '86.00', '65.00', '2110.0', '17.9', '80', 'mazda glc']
['27.9', '4', '156.0', '105.0', '2800.0', '14.4', '80', 'dodge colt']
['40.8', '4', '85.00', '65.00', '2110.0', '19.2', '80', 'datsun 210']
['44.3', '4', '90.00', '48.00', '2085.0', '21.7', '80', 'vw rabbit c (diesel)']
['43.4', '4', '90.00', '48.00', '2335.0', '23.7', '80', 'vw dasher (diesel)']
['36.4', '5', '121.0', '67.00', '2950.0', '19.9', '80', 'audi 5000s (diesel)']
['30.0', '4', '146.0', '67.00', '3250.0', '21.8', '80', 'mercedes-benz 240d']
['44.6', '4', '91.00', '67.00', '1850.0', '13.8', '80', 'honda civic 1500 gl']
['33.8', '4', '97.00', '67.00', '2145.0', '18.0', '80', 'subaru dl']
['29.8', '4', '89.00', '62.00', '1845.0', '15.3', '80', 'vokswagen rabbit']
['32.7', '6', '168.0', '132.0', '2910.0', '11.4', '80', 'datsun 280-zx']
['23.7', '3', '70.00', '100.0', '2420.0', '12.5', '80', 'mazda rx-7 gs']
['35.0', '4', '122.0', '88.00', '2500.0', '15.1', '80', 'triumph tr7 coupe']
['32.4', '4', '107.0', '72.00', '2290.0', '17.0', '80', 'honda accord']
['27.2', '4', '135.0', '84.00', '2490.0', '15.7', '81', 'plymouth reliant']
['26.6', '4', '151.0', '84.00', '2635.0', '16.4', '81', 'buick skylark']
['25.8', '4', '156.0', '92.00', '2620.0', '14.4', '81', 'dodge aries wagon (sw)']
['23.5', '6', '173.0', '110.0', '2725.0', '12.6', '81', 'chevrolet citation']
['30.0', '4', '135.0', '84.00', '2385.0', '12.9', '81', 'plymouth reliant']
['39.1', '4', '79.00', '58.00', '1755.0', '16.9', '81', 'toyota starlet']
['39.0', '4', '86.00', '64.00', '1875.0', '16.4', '81', 'plymouth champ']
['35.1', '4', '81.00', '60.00', '1760.0', '16.1', '81', 'honda civic 1300']
['32.3', '4', '97.00', '67.00', '2065.0', '17.8', '81', 'subaru']
['37.0', '4', '85.00', '65.00', '1975.0', '19.4', '81', 'datsun 210 mpg']
['37.7', '4', '89.00', '62.00', '2050.0', '17.3', '81', 'toyota tercel']
['34.1', '4', '91.00', '68.00', '1985.0', '16.0', '81', 'mazda glc 4']
['34.7', '4', '105.0', '63.00', '2215.0', '14.9', '81', 'plymouth horizon 4']
['34.4', '4', '98.00', '65.00', '2045.0', '16.2', '81', 'ford escort 4w']
['29.9', '4', '98.00', '65.00', '2380.0', '20.7', '81', 'ford escort 2h']
['33.0', '4', '105.0', '74.00', '2190.0', '14.2', '81', 'volkswagen jetta']
['33.7', '4', '107.0', '75.00', '2210.0', '14.4', '81', 'honda prelude']
['32.4', '4', '108.0', '75.00', '2350.0', '16.8', '81', 'toyota corolla']
['32.9', '4', '119.0', '100.0', '2615.0', '14.8', '81', 'datsun 200sx']
['31.6', '4', '120.0', '74.00', '2635.0', '18.3', '81', 'mazda 626']
['28.1', '4', '141.0', '80.00', '3230.0', '20.4', '81', 'peugeot 505s turbo diesel']
['30.7', '6', '145.0', '76.00', '3160.0', '19.6', '81', 'volvo diesel']
['25.4', '6', '168.0', '116.0', '2900.0', '12.6', '81', 'toyota cressida']
['24.2', '6', '146.0', '120.0', '2930.0', '13.8', '81', 'datsun 810 maxima']
['22.4', '6', '231.0', '110.0', '3415.0', '15.8', '81', 'buick century']
['26.6', '8', '350.0', '105.0', '3725.0', '19.0', '81', 'oldsmobile cutlass ls']
['20.2', '6', '200.0', '88.00', '3060.0', '17.1', '81', 'ford granada gl']
['17.6', '6', '225.0', '85.00', '3465.0', '16.6', '81', 'chrysler lebaron salon']
['28.0', '4', '112.0', '88.00', '2605.0', '19.6', '82', 'chevrolet cavalier']
['27.0', '4', '112.0', '88.00', '2640.0', '18.6', '82', 'chevrolet cavalier wagon']
['34.0', '4', '112.0', '88.00', '2395.0', '18.0', '82', 'chevrolet cavalier 2-door']
['31.0', '4', '112.0', '85.00', '2575.0', '16.2', '82', 'pontiac j2000 se hatchback']
['29.0', '4', '135.0', '84.00', '2525.0', '16.0', '82', 'dodge aries se']
['27.0', '4', '151.0', '90.00', '2735.0', '18.0', '82', 'pontiac phoenix']
['24.0', '4', '140.0', '92.00', '2865.0', '16.4', '82', 'ford fairmont futura']
['36.0', '4', '105.0', '74.00', '1980.0', '15.3', '82', 'volkswagen rabbit l']
['37.0', '4', '91.00', '68.00', '2025.0', '18.2', '82', 'mazda glc custom l']
['31.0', '4', '91.00', '68.00', '1970.0', '17.6', '82', 'mazda glc custom']
['38.0', '4', '105.0', '63.00', '2125.0', '14.7', '82', 'plymouth horizon miser']
['36.0', '4', '98.00', '70.00', '2125.0', '17.3', '82', 'mercury lynx l']
['36.0', '4', '120.0', '88.00', '2160.0', '14.5', '82', 'nissan stanza xe']
['36.0', '4', '107.0', '75.00', '2205.0', '14.5', '82', 'honda accord']
['34.0', '4', '108.0', '70.00', '2245.0', '16.9', '82', 'toyota corolla']
['38.0', '4', '91.00', '67.00', '1965.0', '15.0', '82', 'honda civic']
['32.0', '4', '91.00', '67.00', '1965.0', '15.7', '82', 'honda civic (auto)']
['38.0', '4', '91.00', '67.00', '1995.0', '16.2', '82', 'datsun 310 gx']
['25.0', '6', '181.0', '110.0', '2945.0', '16.4', '82', 'buick century limited']
['38.0', '6', '262.0', '85.00', '3015.0', '17.0', '82', 'oldsmobile cutlass ciera (diesel)']
['26.0', '4', '156.0', '92.00', '2585.0', '14.5', '82', 'chrysler lebaron medallion']
['22.0', '6', '232.0', '112.0', '2835.0', '14.7', '82', 'ford granada l']
['32.0', '4', '144.0', '96.00', '2665.0', '13.9', '82', 'toyota celica gt']
['36.0', '4', '135.0', '84.00', '2370.0', '13.0', '82', 'dodge charger 2.2']
['27.0', '4', '151.0', '90.00', '2950.0', '17.3', '82', 'chevrolet camaro']
['27.0', '4', '140.0', '86.00', '2790.0', '15.6', '82', 'ford mustang gl']
['44.0', '4', '97.00', '52.00', '2130.0', '24.6', '82', 'vw pickup']
['32.0', '4', '135.0', '84.00', '2295.0', '11.6', '82', 'dodge rampage']
['28.0', '4', '120.0', '79.00', '2625.0', '18.6', '82', 'ford ranger']
['31.0', '4', '119.0', '82.00', '2720.0', '19.4', '82', 'chevy s-10']

The number of data pairs of the form $\langle \textbf{x}, y \rangle$ that we have read is stored in the variable m.


In [4]:
m = len(mpg)
m


Out[4]:
392

For efficiency reasons we transform the variable Features, which is a the list of list, into a NumPy matrix.


In [5]:
import numpy as np

In [6]:
Features


Out[6]:
[[8.0, 307.0, 130.0, 3504.0, 12.0, 70.0, 1.0],
 [8.0, 350.0, 165.0, 3693.0, 11.5, 70.0, 1.0],
 [8.0, 318.0, 150.0, 3436.0, 11.0, 70.0, 1.0],
 [8.0, 304.0, 150.0, 3433.0, 12.0, 70.0, 1.0],
 [8.0, 302.0, 140.0, 3449.0, 10.5, 70.0, 1.0],
 [8.0, 429.0, 198.0, 4341.0, 10.0, 70.0, 1.0],
 [8.0, 454.0, 220.0, 4354.0, 9.0, 70.0, 1.0],
 [8.0, 440.0, 215.0, 4312.0, 8.5, 70.0, 1.0],
 [8.0, 455.0, 225.0, 4425.0, 10.0, 70.0, 1.0],
 [8.0, 390.0, 190.0, 3850.0, 8.5, 70.0, 1.0],
 [8.0, 383.0, 170.0, 3563.0, 10.0, 70.0, 1.0],
 [8.0, 340.0, 160.0, 3609.0, 8.0, 70.0, 1.0],
 [8.0, 400.0, 150.0, 3761.0, 9.5, 70.0, 1.0],
 [8.0, 455.0, 225.0, 3086.0, 10.0, 70.0, 1.0],
 [4.0, 113.0, 95.0, 2372.0, 15.0, 70.0, 1.0],
 [6.0, 198.0, 95.0, 2833.0, 15.5, 70.0, 1.0],
 [6.0, 199.0, 97.0, 2774.0, 15.5, 70.0, 1.0],
 [6.0, 200.0, 85.0, 2587.0, 16.0, 70.0, 1.0],
 [4.0, 97.0, 88.0, 2130.0, 14.5, 70.0, 1.0],
 [4.0, 97.0, 46.0, 1835.0, 20.5, 70.0, 1.0],
 [4.0, 110.0, 87.0, 2672.0, 17.5, 70.0, 1.0],
 [4.0, 107.0, 90.0, 2430.0, 14.5, 70.0, 1.0],
 [4.0, 104.0, 95.0, 2375.0, 17.5, 70.0, 1.0],
 [4.0, 121.0, 113.0, 2234.0, 12.5, 70.0, 1.0],
 [6.0, 199.0, 90.0, 2648.0, 15.0, 70.0, 1.0],
 [8.0, 360.0, 215.0, 4615.0, 14.0, 70.0, 1.0],
 [8.0, 307.0, 200.0, 4376.0, 15.0, 70.0, 1.0],
 [8.0, 318.0, 210.0, 4382.0, 13.5, 70.0, 1.0],
 [8.0, 304.0, 193.0, 4732.0, 18.5, 70.0, 1.0],
 [4.0, 97.0, 88.0, 2130.0, 14.5, 71.0, 1.0],
 [4.0, 140.0, 90.0, 2264.0, 15.5, 71.0, 1.0],
 [4.0, 113.0, 95.0, 2228.0, 14.0, 71.0, 1.0],
 [6.0, 232.0, 100.0, 2634.0, 13.0, 71.0, 1.0],
 [6.0, 225.0, 105.0, 3439.0, 15.5, 71.0, 1.0],
 [6.0, 250.0, 100.0, 3329.0, 15.5, 71.0, 1.0],
 [6.0, 250.0, 88.0, 3302.0, 15.5, 71.0, 1.0],
 [6.0, 232.0, 100.0, 3288.0, 15.5, 71.0, 1.0],
 [8.0, 350.0, 165.0, 4209.0, 12.0, 71.0, 1.0],
 [8.0, 400.0, 175.0, 4464.0, 11.5, 71.0, 1.0],
 [8.0, 351.0, 153.0, 4154.0, 13.5, 71.0, 1.0],
 [8.0, 318.0, 150.0, 4096.0, 13.0, 71.0, 1.0],
 [8.0, 383.0, 180.0, 4955.0, 11.5, 71.0, 1.0],
 [8.0, 400.0, 170.0, 4746.0, 12.0, 71.0, 1.0],
 [8.0, 400.0, 175.0, 5140.0, 12.0, 71.0, 1.0],
 [6.0, 258.0, 110.0, 2962.0, 13.5, 71.0, 1.0],
 [4.0, 140.0, 72.0, 2408.0, 19.0, 71.0, 1.0],
 [6.0, 250.0, 100.0, 3282.0, 15.0, 71.0, 1.0],
 [6.0, 250.0, 88.0, 3139.0, 14.5, 71.0, 1.0],
 [4.0, 122.0, 86.0, 2220.0, 14.0, 71.0, 1.0],
 [4.0, 116.0, 90.0, 2123.0, 14.0, 71.0, 1.0],
 [4.0, 79.0, 70.0, 2074.0, 19.5, 71.0, 1.0],
 [4.0, 88.0, 76.0, 2065.0, 14.5, 71.0, 1.0],
 [4.0, 71.0, 65.0, 1773.0, 19.0, 71.0, 1.0],
 [4.0, 72.0, 69.0, 1613.0, 18.0, 71.0, 1.0],
 [4.0, 97.0, 60.0, 1834.0, 19.0, 71.0, 1.0],
 [4.0, 91.0, 70.0, 1955.0, 20.5, 71.0, 1.0],
 [4.0, 113.0, 95.0, 2278.0, 15.5, 72.0, 1.0],
 [4.0, 97.5, 80.0, 2126.0, 17.0, 72.0, 1.0],
 [4.0, 97.0, 54.0, 2254.0, 23.5, 72.0, 1.0],
 [4.0, 140.0, 90.0, 2408.0, 19.5, 72.0, 1.0],
 [4.0, 122.0, 86.0, 2226.0, 16.5, 72.0, 1.0],
 [8.0, 350.0, 165.0, 4274.0, 12.0, 72.0, 1.0],
 [8.0, 400.0, 175.0, 4385.0, 12.0, 72.0, 1.0],
 [8.0, 318.0, 150.0, 4135.0, 13.5, 72.0, 1.0],
 [8.0, 351.0, 153.0, 4129.0, 13.0, 72.0, 1.0],
 [8.0, 304.0, 150.0, 3672.0, 11.5, 72.0, 1.0],
 [8.0, 429.0, 208.0, 4633.0, 11.0, 72.0, 1.0],
 [8.0, 350.0, 155.0, 4502.0, 13.5, 72.0, 1.0],
 [8.0, 350.0, 160.0, 4456.0, 13.5, 72.0, 1.0],
 [8.0, 400.0, 190.0, 4422.0, 12.5, 72.0, 1.0],
 [3.0, 70.0, 97.0, 2330.0, 13.5, 72.0, 1.0],
 [8.0, 304.0, 150.0, 3892.0, 12.5, 72.0, 1.0],
 [8.0, 307.0, 130.0, 4098.0, 14.0, 72.0, 1.0],
 [8.0, 302.0, 140.0, 4294.0, 16.0, 72.0, 1.0],
 [8.0, 318.0, 150.0, 4077.0, 14.0, 72.0, 1.0],
 [4.0, 121.0, 112.0, 2933.0, 14.5, 72.0, 1.0],
 [4.0, 121.0, 76.0, 2511.0, 18.0, 72.0, 1.0],
 [4.0, 120.0, 87.0, 2979.0, 19.5, 72.0, 1.0],
 [4.0, 96.0, 69.0, 2189.0, 18.0, 72.0, 1.0],
 [4.0, 122.0, 86.0, 2395.0, 16.0, 72.0, 1.0],
 [4.0, 97.0, 92.0, 2288.0, 17.0, 72.0, 1.0],
 [4.0, 120.0, 97.0, 2506.0, 14.5, 72.0, 1.0],
 [4.0, 98.0, 80.0, 2164.0, 15.0, 72.0, 1.0],
 [4.0, 97.0, 88.0, 2100.0, 16.5, 72.0, 1.0],
 [8.0, 350.0, 175.0, 4100.0, 13.0, 73.0, 1.0],
 [8.0, 304.0, 150.0, 3672.0, 11.5, 73.0, 1.0],
 [8.0, 350.0, 145.0, 3988.0, 13.0, 73.0, 1.0],
 [8.0, 302.0, 137.0, 4042.0, 14.5, 73.0, 1.0],
 [8.0, 318.0, 150.0, 3777.0, 12.5, 73.0, 1.0],
 [8.0, 429.0, 198.0, 4952.0, 11.5, 73.0, 1.0],
 [8.0, 400.0, 150.0, 4464.0, 12.0, 73.0, 1.0],
 [8.0, 351.0, 158.0, 4363.0, 13.0, 73.0, 1.0],
 [8.0, 318.0, 150.0, 4237.0, 14.5, 73.0, 1.0],
 [8.0, 440.0, 215.0, 4735.0, 11.0, 73.0, 1.0],
 [8.0, 455.0, 225.0, 4951.0, 11.0, 73.0, 1.0],
 [8.0, 360.0, 175.0, 3821.0, 11.0, 73.0, 1.0],
 [6.0, 225.0, 105.0, 3121.0, 16.5, 73.0, 1.0],
 [6.0, 250.0, 100.0, 3278.0, 18.0, 73.0, 1.0],
 [6.0, 232.0, 100.0, 2945.0, 16.0, 73.0, 1.0],
 [6.0, 250.0, 88.0, 3021.0, 16.5, 73.0, 1.0],
 [6.0, 198.0, 95.0, 2904.0, 16.0, 73.0, 1.0],
 [4.0, 97.0, 46.0, 1950.0, 21.0, 73.0, 1.0],
 [8.0, 400.0, 150.0, 4997.0, 14.0, 73.0, 1.0],
 [8.0, 400.0, 167.0, 4906.0, 12.5, 73.0, 1.0],
 [8.0, 360.0, 170.0, 4654.0, 13.0, 73.0, 1.0],
 [8.0, 350.0, 180.0, 4499.0, 12.5, 73.0, 1.0],
 [6.0, 232.0, 100.0, 2789.0, 15.0, 73.0, 1.0],
 [4.0, 97.0, 88.0, 2279.0, 19.0, 73.0, 1.0],
 [4.0, 140.0, 72.0, 2401.0, 19.5, 73.0, 1.0],
 [4.0, 108.0, 94.0, 2379.0, 16.5, 73.0, 1.0],
 [3.0, 70.0, 90.0, 2124.0, 13.5, 73.0, 1.0],
 [4.0, 122.0, 85.0, 2310.0, 18.5, 73.0, 1.0],
 [6.0, 155.0, 107.0, 2472.0, 14.0, 73.0, 1.0],
 [4.0, 98.0, 90.0, 2265.0, 15.5, 73.0, 1.0],
 [8.0, 350.0, 145.0, 4082.0, 13.0, 73.0, 1.0],
 [8.0, 400.0, 230.0, 4278.0, 9.5, 73.0, 1.0],
 [4.0, 68.0, 49.0, 1867.0, 19.5, 73.0, 1.0],
 [4.0, 116.0, 75.0, 2158.0, 15.5, 73.0, 1.0],
 [4.0, 114.0, 91.0, 2582.0, 14.0, 73.0, 1.0],
 [4.0, 121.0, 112.0, 2868.0, 15.5, 73.0, 1.0],
 [8.0, 318.0, 150.0, 3399.0, 11.0, 73.0, 1.0],
 [4.0, 121.0, 110.0, 2660.0, 14.0, 73.0, 1.0],
 [6.0, 156.0, 122.0, 2807.0, 13.5, 73.0, 1.0],
 [8.0, 350.0, 180.0, 3664.0, 11.0, 73.0, 1.0],
 [6.0, 198.0, 95.0, 3102.0, 16.5, 74.0, 1.0],
 [6.0, 232.0, 100.0, 2901.0, 16.0, 74.0, 1.0],
 [6.0, 250.0, 100.0, 3336.0, 17.0, 74.0, 1.0],
 [4.0, 79.0, 67.0, 1950.0, 19.0, 74.0, 1.0],
 [4.0, 122.0, 80.0, 2451.0, 16.5, 74.0, 1.0],
 [4.0, 71.0, 65.0, 1836.0, 21.0, 74.0, 1.0],
 [4.0, 140.0, 75.0, 2542.0, 17.0, 74.0, 1.0],
 [6.0, 250.0, 100.0, 3781.0, 17.0, 74.0, 1.0],
 [6.0, 258.0, 110.0, 3632.0, 18.0, 74.0, 1.0],
 [6.0, 225.0, 105.0, 3613.0, 16.5, 74.0, 1.0],
 [8.0, 302.0, 140.0, 4141.0, 14.0, 74.0, 1.0],
 [8.0, 350.0, 150.0, 4699.0, 14.5, 74.0, 1.0],
 [8.0, 318.0, 150.0, 4457.0, 13.5, 74.0, 1.0],
 [8.0, 302.0, 140.0, 4638.0, 16.0, 74.0, 1.0],
 [8.0, 304.0, 150.0, 4257.0, 15.5, 74.0, 1.0],
 [4.0, 98.0, 83.0, 2219.0, 16.5, 74.0, 1.0],
 [4.0, 79.0, 67.0, 1963.0, 15.5, 74.0, 1.0],
 [4.0, 97.0, 78.0, 2300.0, 14.5, 74.0, 1.0],
 [4.0, 76.0, 52.0, 1649.0, 16.5, 74.0, 1.0],
 [4.0, 83.0, 61.0, 2003.0, 19.0, 74.0, 1.0],
 [4.0, 90.0, 75.0, 2125.0, 14.5, 74.0, 1.0],
 [4.0, 90.0, 75.0, 2108.0, 15.5, 74.0, 1.0],
 [4.0, 116.0, 75.0, 2246.0, 14.0, 74.0, 1.0],
 [4.0, 120.0, 97.0, 2489.0, 15.0, 74.0, 1.0],
 [4.0, 108.0, 93.0, 2391.0, 15.5, 74.0, 1.0],
 [4.0, 79.0, 67.0, 2000.0, 16.0, 74.0, 1.0],
 [6.0, 225.0, 95.0, 3264.0, 16.0, 75.0, 1.0],
 [6.0, 250.0, 105.0, 3459.0, 16.0, 75.0, 1.0],
 [6.0, 250.0, 72.0, 3432.0, 21.0, 75.0, 1.0],
 [6.0, 250.0, 72.0, 3158.0, 19.5, 75.0, 1.0],
 [8.0, 400.0, 170.0, 4668.0, 11.5, 75.0, 1.0],
 [8.0, 350.0, 145.0, 4440.0, 14.0, 75.0, 1.0],
 [8.0, 318.0, 150.0, 4498.0, 14.5, 75.0, 1.0],
 [8.0, 351.0, 148.0, 4657.0, 13.5, 75.0, 1.0],
 [6.0, 231.0, 110.0, 3907.0, 21.0, 75.0, 1.0],
 [6.0, 250.0, 105.0, 3897.0, 18.5, 75.0, 1.0],
 [6.0, 258.0, 110.0, 3730.0, 19.0, 75.0, 1.0],
 [6.0, 225.0, 95.0, 3785.0, 19.0, 75.0, 1.0],
 [6.0, 231.0, 110.0, 3039.0, 15.0, 75.0, 1.0],
 [8.0, 262.0, 110.0, 3221.0, 13.5, 75.0, 1.0],
 [8.0, 302.0, 129.0, 3169.0, 12.0, 75.0, 1.0],
 [4.0, 97.0, 75.0, 2171.0, 16.0, 75.0, 1.0],
 [4.0, 140.0, 83.0, 2639.0, 17.0, 75.0, 1.0],
 [6.0, 232.0, 100.0, 2914.0, 16.0, 75.0, 1.0],
 [4.0, 140.0, 78.0, 2592.0, 18.5, 75.0, 1.0],
 [4.0, 134.0, 96.0, 2702.0, 13.5, 75.0, 1.0],
 [4.0, 90.0, 71.0, 2223.0, 16.5, 75.0, 1.0],
 [4.0, 119.0, 97.0, 2545.0, 17.0, 75.0, 1.0],
 [6.0, 171.0, 97.0, 2984.0, 14.5, 75.0, 1.0],
 [4.0, 90.0, 70.0, 1937.0, 14.0, 75.0, 1.0],
 [6.0, 232.0, 90.0, 3211.0, 17.0, 75.0, 1.0],
 [4.0, 115.0, 95.0, 2694.0, 15.0, 75.0, 1.0],
 [4.0, 120.0, 88.0, 2957.0, 17.0, 75.0, 1.0],
 [4.0, 121.0, 98.0, 2945.0, 14.5, 75.0, 1.0],
 [4.0, 121.0, 115.0, 2671.0, 13.5, 75.0, 1.0],
 [4.0, 91.0, 53.0, 1795.0, 17.5, 75.0, 1.0],
 [4.0, 107.0, 86.0, 2464.0, 15.5, 76.0, 1.0],
 [4.0, 116.0, 81.0, 2220.0, 16.9, 76.0, 1.0],
 [4.0, 140.0, 92.0, 2572.0, 14.9, 76.0, 1.0],
 [4.0, 98.0, 79.0, 2255.0, 17.7, 76.0, 1.0],
 [4.0, 101.0, 83.0, 2202.0, 15.3, 76.0, 1.0],
 [8.0, 305.0, 140.0, 4215.0, 13.0, 76.0, 1.0],
 [8.0, 318.0, 150.0, 4190.0, 13.0, 76.0, 1.0],
 [8.0, 304.0, 120.0, 3962.0, 13.9, 76.0, 1.0],
 [8.0, 351.0, 152.0, 4215.0, 12.8, 76.0, 1.0],
 [6.0, 225.0, 100.0, 3233.0, 15.4, 76.0, 1.0],
 [6.0, 250.0, 105.0, 3353.0, 14.5, 76.0, 1.0],
 [6.0, 200.0, 81.0, 3012.0, 17.6, 76.0, 1.0],
 [6.0, 232.0, 90.0, 3085.0, 17.6, 76.0, 1.0],
 [4.0, 85.0, 52.0, 2035.0, 22.2, 76.0, 1.0],
 [4.0, 98.0, 60.0, 2164.0, 22.1, 76.0, 1.0],
 [4.0, 90.0, 70.0, 1937.0, 14.2, 76.0, 1.0],
 [4.0, 91.0, 53.0, 1795.0, 17.4, 76.0, 1.0],
 [6.0, 225.0, 100.0, 3651.0, 17.7, 76.0, 1.0],
 [6.0, 250.0, 78.0, 3574.0, 21.0, 76.0, 1.0],
 [6.0, 250.0, 110.0, 3645.0, 16.2, 76.0, 1.0],
 [6.0, 258.0, 95.0, 3193.0, 17.8, 76.0, 1.0],
 [4.0, 97.0, 71.0, 1825.0, 12.2, 76.0, 1.0],
 [4.0, 85.0, 70.0, 1990.0, 17.0, 76.0, 1.0],
 [4.0, 97.0, 75.0, 2155.0, 16.4, 76.0, 1.0],
 [4.0, 140.0, 72.0, 2565.0, 13.6, 76.0, 1.0],
 [4.0, 130.0, 102.0, 3150.0, 15.7, 76.0, 1.0],
 [8.0, 318.0, 150.0, 3940.0, 13.2, 76.0, 1.0],
 [4.0, 120.0, 88.0, 3270.0, 21.9, 76.0, 1.0],
 [6.0, 156.0, 108.0, 2930.0, 15.5, 76.0, 1.0],
 [6.0, 168.0, 120.0, 3820.0, 16.7, 76.0, 1.0],
 [8.0, 350.0, 180.0, 4380.0, 12.1, 76.0, 1.0],
 [8.0, 350.0, 145.0, 4055.0, 12.0, 76.0, 1.0],
 [8.0, 302.0, 130.0, 3870.0, 15.0, 76.0, 1.0],
 [8.0, 318.0, 150.0, 3755.0, 14.0, 76.0, 1.0],
 [4.0, 98.0, 68.0, 2045.0, 18.5, 77.0, 1.0],
 [4.0, 111.0, 80.0, 2155.0, 14.8, 77.0, 1.0],
 [4.0, 79.0, 58.0, 1825.0, 18.6, 77.0, 1.0],
 [4.0, 122.0, 96.0, 2300.0, 15.5, 77.0, 1.0],
 [4.0, 85.0, 70.0, 1945.0, 16.8, 77.0, 1.0],
 [8.0, 305.0, 145.0, 3880.0, 12.5, 77.0, 1.0],
 [8.0, 260.0, 110.0, 4060.0, 19.0, 77.0, 1.0],
 [8.0, 318.0, 145.0, 4140.0, 13.7, 77.0, 1.0],
 [8.0, 302.0, 130.0, 4295.0, 14.9, 77.0, 1.0],
 [6.0, 250.0, 110.0, 3520.0, 16.4, 77.0, 1.0],
 [6.0, 231.0, 105.0, 3425.0, 16.9, 77.0, 1.0],
 [6.0, 225.0, 100.0, 3630.0, 17.7, 77.0, 1.0],
 [6.0, 250.0, 98.0, 3525.0, 19.0, 77.0, 1.0],
 [8.0, 400.0, 180.0, 4220.0, 11.1, 77.0, 1.0],
 [8.0, 350.0, 170.0, 4165.0, 11.4, 77.0, 1.0],
 [8.0, 400.0, 190.0, 4325.0, 12.2, 77.0, 1.0],
 [8.0, 351.0, 149.0, 4335.0, 14.5, 77.0, 1.0],
 [4.0, 97.0, 78.0, 1940.0, 14.5, 77.0, 1.0],
 [4.0, 151.0, 88.0, 2740.0, 16.0, 77.0, 1.0],
 [4.0, 97.0, 75.0, 2265.0, 18.2, 77.0, 1.0],
 [4.0, 140.0, 89.0, 2755.0, 15.8, 77.0, 1.0],
 [4.0, 98.0, 63.0, 2051.0, 17.0, 77.0, 1.0],
 [4.0, 98.0, 83.0, 2075.0, 15.9, 77.0, 1.0],
 [4.0, 97.0, 67.0, 1985.0, 16.4, 77.0, 1.0],
 [4.0, 97.0, 78.0, 2190.0, 14.1, 77.0, 1.0],
 [6.0, 146.0, 97.0, 2815.0, 14.5, 77.0, 1.0],
 [4.0, 121.0, 110.0, 2600.0, 12.8, 77.0, 1.0],
 [3.0, 80.0, 110.0, 2720.0, 13.5, 77.0, 1.0],
 [4.0, 90.0, 48.0, 1985.0, 21.5, 78.0, 1.0],
 [4.0, 98.0, 66.0, 1800.0, 14.4, 78.0, 1.0],
 [4.0, 78.0, 52.0, 1985.0, 19.4, 78.0, 1.0],
 [4.0, 85.0, 70.0, 2070.0, 18.6, 78.0, 1.0],
 [4.0, 91.0, 60.0, 1800.0, 16.4, 78.0, 1.0],
 [8.0, 260.0, 110.0, 3365.0, 15.5, 78.0, 1.0],
 [8.0, 318.0, 140.0, 3735.0, 13.2, 78.0, 1.0],
 [8.0, 302.0, 139.0, 3570.0, 12.8, 78.0, 1.0],
 [6.0, 231.0, 105.0, 3535.0, 19.2, 78.0, 1.0],
 [6.0, 200.0, 95.0, 3155.0, 18.2, 78.0, 1.0],
 [6.0, 200.0, 85.0, 2965.0, 15.8, 78.0, 1.0],
 [4.0, 140.0, 88.0, 2720.0, 15.4, 78.0, 1.0],
 [6.0, 225.0, 100.0, 3430.0, 17.2, 78.0, 1.0],
 [6.0, 232.0, 90.0, 3210.0, 17.2, 78.0, 1.0],
 [6.0, 231.0, 105.0, 3380.0, 15.8, 78.0, 1.0],
 [6.0, 200.0, 85.0, 3070.0, 16.7, 78.0, 1.0],
 [6.0, 225.0, 110.0, 3620.0, 18.7, 78.0, 1.0],
 [6.0, 258.0, 120.0, 3410.0, 15.1, 78.0, 1.0],
 [8.0, 305.0, 145.0, 3425.0, 13.2, 78.0, 1.0],
 [6.0, 231.0, 165.0, 3445.0, 13.4, 78.0, 1.0],
 [8.0, 302.0, 139.0, 3205.0, 11.2, 78.0, 1.0],
 [8.0, 318.0, 140.0, 4080.0, 13.7, 78.0, 1.0],
 [4.0, 98.0, 68.0, 2155.0, 16.5, 78.0, 1.0],
 [4.0, 134.0, 95.0, 2560.0, 14.2, 78.0, 1.0],
 [4.0, 119.0, 97.0, 2300.0, 14.7, 78.0, 1.0],
 [4.0, 105.0, 75.0, 2230.0, 14.5, 78.0, 1.0],
 [4.0, 134.0, 95.0, 2515.0, 14.8, 78.0, 1.0],
 [4.0, 156.0, 105.0, 2745.0, 16.7, 78.0, 1.0],
 [4.0, 151.0, 85.0, 2855.0, 17.6, 78.0, 1.0],
 [4.0, 119.0, 97.0, 2405.0, 14.9, 78.0, 1.0],
 [5.0, 131.0, 103.0, 2830.0, 15.9, 78.0, 1.0],
 [6.0, 163.0, 125.0, 3140.0, 13.6, 78.0, 1.0],
 [4.0, 121.0, 115.0, 2795.0, 15.7, 78.0, 1.0],
 [6.0, 163.0, 133.0, 3410.0, 15.8, 78.0, 1.0],
 [4.0, 89.0, 71.0, 1990.0, 14.9, 78.0, 1.0],
 [4.0, 98.0, 68.0, 2135.0, 16.6, 78.0, 1.0],
 [6.0, 231.0, 115.0, 3245.0, 15.4, 79.0, 1.0],
 [6.0, 200.0, 85.0, 2990.0, 18.2, 79.0, 1.0],
 [4.0, 140.0, 88.0, 2890.0, 17.3, 79.0, 1.0],
 [6.0, 232.0, 90.0, 3265.0, 18.2, 79.0, 1.0],
 [6.0, 225.0, 110.0, 3360.0, 16.6, 79.0, 1.0],
 [8.0, 305.0, 130.0, 3840.0, 15.4, 79.0, 1.0],
 [8.0, 302.0, 129.0, 3725.0, 13.4, 79.0, 1.0],
 [8.0, 351.0, 138.0, 3955.0, 13.2, 79.0, 1.0],
 [8.0, 318.0, 135.0, 3830.0, 15.2, 79.0, 1.0],
 [8.0, 350.0, 155.0, 4360.0, 14.9, 79.0, 1.0],
 [8.0, 351.0, 142.0, 4054.0, 14.3, 79.0, 1.0],
 [8.0, 267.0, 125.0, 3605.0, 15.0, 79.0, 1.0],
 [8.0, 360.0, 150.0, 3940.0, 13.0, 79.0, 1.0],
 [4.0, 89.0, 71.0, 1925.0, 14.0, 79.0, 1.0],
 [4.0, 86.0, 65.0, 1975.0, 15.2, 79.0, 1.0],
 [4.0, 98.0, 80.0, 1915.0, 14.4, 79.0, 1.0],
 [4.0, 121.0, 80.0, 2670.0, 15.0, 79.0, 1.0],
 [5.0, 183.0, 77.0, 3530.0, 20.1, 79.0, 1.0],
 [8.0, 350.0, 125.0, 3900.0, 17.4, 79.0, 1.0],
 [4.0, 141.0, 71.0, 3190.0, 24.8, 79.0, 1.0],
 [8.0, 260.0, 90.0, 3420.0, 22.2, 79.0, 1.0],
 [4.0, 105.0, 70.0, 2200.0, 13.2, 79.0, 1.0],
 [4.0, 105.0, 70.0, 2150.0, 14.9, 79.0, 1.0],
 [4.0, 85.0, 65.0, 2020.0, 19.2, 79.0, 1.0],
 [4.0, 91.0, 69.0, 2130.0, 14.7, 79.0, 1.0],
 [4.0, 151.0, 90.0, 2670.0, 16.0, 79.0, 1.0],
 [6.0, 173.0, 115.0, 2595.0, 11.3, 79.0, 1.0],
 [6.0, 173.0, 115.0, 2700.0, 12.9, 79.0, 1.0],
 [4.0, 151.0, 90.0, 2556.0, 13.2, 79.0, 1.0],
 [4.0, 98.0, 76.0, 2144.0, 14.7, 80.0, 1.0],
 [4.0, 89.0, 60.0, 1968.0, 18.8, 80.0, 1.0],
 [4.0, 98.0, 70.0, 2120.0, 15.5, 80.0, 1.0],
 [4.0, 86.0, 65.0, 2019.0, 16.4, 80.0, 1.0],
 [4.0, 151.0, 90.0, 2678.0, 16.5, 80.0, 1.0],
 [4.0, 140.0, 88.0, 2870.0, 18.1, 80.0, 1.0],
 [4.0, 151.0, 90.0, 3003.0, 20.1, 80.0, 1.0],
 [6.0, 225.0, 90.0, 3381.0, 18.7, 80.0, 1.0],
 [4.0, 97.0, 78.0, 2188.0, 15.8, 80.0, 1.0],
 [4.0, 134.0, 90.0, 2711.0, 15.5, 80.0, 1.0],
 [4.0, 120.0, 75.0, 2542.0, 17.5, 80.0, 1.0],
 [4.0, 119.0, 92.0, 2434.0, 15.0, 80.0, 1.0],
 [4.0, 108.0, 75.0, 2265.0, 15.2, 80.0, 1.0],
 [4.0, 86.0, 65.0, 2110.0, 17.9, 80.0, 1.0],
 [4.0, 156.0, 105.0, 2800.0, 14.4, 80.0, 1.0],
 [4.0, 85.0, 65.0, 2110.0, 19.2, 80.0, 1.0],
 [4.0, 90.0, 48.0, 2085.0, 21.7, 80.0, 1.0],
 [4.0, 90.0, 48.0, 2335.0, 23.7, 80.0, 1.0],
 [5.0, 121.0, 67.0, 2950.0, 19.9, 80.0, 1.0],
 [4.0, 146.0, 67.0, 3250.0, 21.8, 80.0, 1.0],
 [4.0, 91.0, 67.0, 1850.0, 13.8, 80.0, 1.0],
 [4.0, 97.0, 67.0, 2145.0, 18.0, 80.0, 1.0],
 [4.0, 89.0, 62.0, 1845.0, 15.3, 80.0, 1.0],
 [6.0, 168.0, 132.0, 2910.0, 11.4, 80.0, 1.0],
 [3.0, 70.0, 100.0, 2420.0, 12.5, 80.0, 1.0],
 [4.0, 122.0, 88.0, 2500.0, 15.1, 80.0, 1.0],
 [4.0, 107.0, 72.0, 2290.0, 17.0, 80.0, 1.0],
 [4.0, 135.0, 84.0, 2490.0, 15.7, 81.0, 1.0],
 [4.0, 151.0, 84.0, 2635.0, 16.4, 81.0, 1.0],
 [4.0, 156.0, 92.0, 2620.0, 14.4, 81.0, 1.0],
 [6.0, 173.0, 110.0, 2725.0, 12.6, 81.0, 1.0],
 [4.0, 135.0, 84.0, 2385.0, 12.9, 81.0, 1.0],
 [4.0, 79.0, 58.0, 1755.0, 16.9, 81.0, 1.0],
 [4.0, 86.0, 64.0, 1875.0, 16.4, 81.0, 1.0],
 [4.0, 81.0, 60.0, 1760.0, 16.1, 81.0, 1.0],
 [4.0, 97.0, 67.0, 2065.0, 17.8, 81.0, 1.0],
 [4.0, 85.0, 65.0, 1975.0, 19.4, 81.0, 1.0],
 [4.0, 89.0, 62.0, 2050.0, 17.3, 81.0, 1.0],
 [4.0, 91.0, 68.0, 1985.0, 16.0, 81.0, 1.0],
 [4.0, 105.0, 63.0, 2215.0, 14.9, 81.0, 1.0],
 [4.0, 98.0, 65.0, 2045.0, 16.2, 81.0, 1.0],
 [4.0, 98.0, 65.0, 2380.0, 20.7, 81.0, 1.0],
 [4.0, 105.0, 74.0, 2190.0, 14.2, 81.0, 1.0],
 [4.0, 107.0, 75.0, 2210.0, 14.4, 81.0, 1.0],
 [4.0, 108.0, 75.0, 2350.0, 16.8, 81.0, 1.0],
 [4.0, 119.0, 100.0, 2615.0, 14.8, 81.0, 1.0],
 [4.0, 120.0, 74.0, 2635.0, 18.3, 81.0, 1.0],
 [4.0, 141.0, 80.0, 3230.0, 20.4, 81.0, 1.0],
 [6.0, 145.0, 76.0, 3160.0, 19.6, 81.0, 1.0],
 [6.0, 168.0, 116.0, 2900.0, 12.6, 81.0, 1.0],
 [6.0, 146.0, 120.0, 2930.0, 13.8, 81.0, 1.0],
 [6.0, 231.0, 110.0, 3415.0, 15.8, 81.0, 1.0],
 [8.0, 350.0, 105.0, 3725.0, 19.0, 81.0, 1.0],
 [6.0, 200.0, 88.0, 3060.0, 17.1, 81.0, 1.0],
 [6.0, 225.0, 85.0, 3465.0, 16.6, 81.0, 1.0],
 [4.0, 112.0, 88.0, 2605.0, 19.6, 82.0, 1.0],
 [4.0, 112.0, 88.0, 2640.0, 18.6, 82.0, 1.0],
 [4.0, 112.0, 88.0, 2395.0, 18.0, 82.0, 1.0],
 [4.0, 112.0, 85.0, 2575.0, 16.2, 82.0, 1.0],
 [4.0, 135.0, 84.0, 2525.0, 16.0, 82.0, 1.0],
 [4.0, 151.0, 90.0, 2735.0, 18.0, 82.0, 1.0],
 [4.0, 140.0, 92.0, 2865.0, 16.4, 82.0, 1.0],
 [4.0, 105.0, 74.0, 1980.0, 15.3, 82.0, 1.0],
 [4.0, 91.0, 68.0, 2025.0, 18.2, 82.0, 1.0],
 [4.0, 91.0, 68.0, 1970.0, 17.6, 82.0, 1.0],
 [4.0, 105.0, 63.0, 2125.0, 14.7, 82.0, 1.0],
 [4.0, 98.0, 70.0, 2125.0, 17.3, 82.0, 1.0],
 [4.0, 120.0, 88.0, 2160.0, 14.5, 82.0, 1.0],
 [4.0, 107.0, 75.0, 2205.0, 14.5, 82.0, 1.0],
 [4.0, 108.0, 70.0, 2245.0, 16.9, 82.0, 1.0],
 [4.0, 91.0, 67.0, 1965.0, 15.0, 82.0, 1.0],
 [4.0, 91.0, 67.0, 1965.0, 15.7, 82.0, 1.0],
 [4.0, 91.0, 67.0, 1995.0, 16.2, 82.0, 1.0],
 [6.0, 181.0, 110.0, 2945.0, 16.4, 82.0, 1.0],
 [6.0, 262.0, 85.0, 3015.0, 17.0, 82.0, 1.0],
 [4.0, 156.0, 92.0, 2585.0, 14.5, 82.0, 1.0],
 [6.0, 232.0, 112.0, 2835.0, 14.7, 82.0, 1.0],
 [4.0, 144.0, 96.0, 2665.0, 13.9, 82.0, 1.0],
 [4.0, 135.0, 84.0, 2370.0, 13.0, 82.0, 1.0],
 [4.0, 151.0, 90.0, 2950.0, 17.3, 82.0, 1.0],
 [4.0, 140.0, 86.0, 2790.0, 15.6, 82.0, 1.0],
 [4.0, 97.0, 52.0, 2130.0, 24.6, 82.0, 1.0],
 [4.0, 135.0, 84.0, 2295.0, 11.6, 82.0, 1.0],
 [4.0, 120.0, 79.0, 2625.0, 18.6, 82.0, 1.0],
 [4.0, 119.0, 82.0, 2720.0, 19.4, 82.0, 1.0]]

In [7]:
X = np.array(Features)
X


Out[7]:
array([[  8. , 307. , 130. , ...,  12. ,  70. ,   1. ],
       [  8. , 350. , 165. , ...,  11.5,  70. ,   1. ],
       [  8. , 318. , 150. , ...,  11. ,  70. ,   1. ],
       ...,
       [  4. , 135. ,  84. , ...,  11.6,  82. ,   1. ],
       [  4. , 120. ,  79. , ...,  18.6,  82. ,   1. ],
       [  4. , 119. ,  82. , ...,  19.4,  82. ,   1. ]])

Note that every row in this matrix corresponds to the data of one car.

Since miles per gallon is the inverse of the fuel consumption, the vector Y is defined as the reciprocal of the variable mpg.


In [8]:
y = np.array([1 / mpg[i] for i in range(m)])

The weight vector w is specified via the normal equation: $$ (X^\top \cdot X) \cdot \textbf{w} = X^\top \cdot \textbf{y} $$ This linear equation can be solved for w using the method np.linalg.solve. Note how the transpose of the matrix X can be computed by writing X.T.


In [9]:
%%time
w = np.linalg.solve(X.T @ X, X.T @ y)
print(w)


[ 1.39205897e-03 -1.70283082e-05  1.13756363e-04  1.10909594e-05
  3.38800847e-04 -1.26596723e-03  8.95296095e-02]
CPU times: user 4.12 ms, sys: 2 ms, total: 6.12 ms
Wall time: 4.89 ms

The residual sum of squares is given by the following sum: $$ \texttt{RSS} = \sum\limits_{i=1}^m \Bigl(\bigl(\textbf{x}^{(i)}\bigr)^\top \cdot \textbf{w} - y_i\Bigr)^2 $$ Here $\textbf{x}^{(i)}$ is the $i$-th row of the matrix $X$, while $y_i$ is the $i$-th component of the vector $\textbf{y}$. The expression $\bigl(\textbf{x}^{(i)}\bigr)^\top \cdot \textbf{w}$ is the predicted value of the linear model, while $y_i$ is the actual value. As the feature Matrix $X$ is defined as $$ X = \left( \begin{array}{c} \bigl(\textbf{x}^{(1)}\bigr)^\top \\ \vdots \\ \bigl(\textbf{x}^{(m)}\bigr)^\top \end{array} \right) $$ we can compute RSS as follows:


In [10]:
RSS = np.sum((X @ w - y) ** 2)

We compute the average fuel consumption $\bar{\mathbf{y}}$ according to the formula: $$ \bar{\mathbf{y}} = \frac{1}{m} \cdot \sum\limits_{i=1}^m y_i $$


In [11]:
yMean = np.mean(y)
yMean


Out[11]:
0.04782242789602457

We compute the total sum of squares TSSaccording to the following formula: $$ \mathtt{TSS} := \sum\limits_{i=1}^m \bigl(y_i - \bar{\mathbf{y}}\bigr)^2 $$


In [12]:
TSS = np.sum((y - yMean) ** 2)
TSS


Out[12]:
0.10825652135293372

Now the proportion of explained variance $R^2$ is calculated via the formula: $$ R^2 = 1 - \frac{\mathtt{RSS}}{\mathtt{TSS}}$$


In [13]:
R2 = 1 - RSS/TSS
R2


Out[13]:
0.8838956283269112

We can explain about $88\%$ of the fuel consumption by the data given in our CSV file. Given that our data does not contain any parameters describing the air resistance this result seems reasonable.


In [ ]: